﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="CadastroIteracoes.aspx.cs" Inherits="Pos_Projeto.Protegido.CadastroIteracoes" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>

            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                CellPadding="4" DataKeyNames="CodigoIteracao" DataSourceID="SqlDataSource1" 
                ForeColor="#333333" GridLines="None">
                <AlternatingRowStyle BackColor="White" />
                <Columns>
                    <asp:CommandField ButtonType="Button" SelectText="&gt;&gt;&gt;&gt;" 
                        ShowSelectButton="True" />
                    <asp:BoundField DataField="CodigoIteracao" HeaderText="CodigoIteracao" 
                        InsertVisible="False" ReadOnly="True" SortExpression="CodigoIteracao" />
                    <asp:BoundField DataField="CodigoProjeto" HeaderText="CodigoProjeto" 
                        SortExpression="CodigoProjeto" />
                    <asp:BoundField DataField="NomeIteracao" HeaderText="NomeIteracao" 
                        SortExpression="NomeIteracao" />
                    <asp:BoundField DataField="DataInicioIteracao" HeaderText="DataInicioIteracao" 
                        SortExpression="DataInicioIteracao" />
                    <asp:BoundField DataField="DataTerminoIteracao" 
                        HeaderText="DataTerminoIteracao" SortExpression="DataTerminoIteracao" />
                </Columns>
                <EditRowStyle BackColor="#7C6F57" />
                <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#E3EAEB" />
                <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#F8FAFA" />
                <SortedAscendingHeaderStyle BackColor="#246B61" />
                <SortedDescendingCellStyle BackColor="#D4DFE1" />
                <SortedDescendingHeaderStyle BackColor="#15524A" />
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                ConflictDetection="CompareAllValues" 
                ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" 
                DeleteCommand="DELETE FROM [Iteracoes] WHERE [CodigoIteracao] = @original_CodigoIteracao AND [CodigoProjeto] = @original_CodigoProjeto AND [NomeIteracao] = @original_NomeIteracao AND [DataInicioIteracao] = @original_DataInicioIteracao AND [DataTerminoIteracao] = @original_DataTerminoIteracao" 
                InsertCommand="INSERT INTO [Iteracoes] ([CodigoProjeto], [NomeIteracao], [DataInicioIteracao], [DataTerminoIteracao]) VALUES (@CodigoProjeto, @NomeIteracao, @DataInicioIteracao, @DataTerminoIteracao)" 
                OldValuesParameterFormatString="original_{0}" 
                SelectCommand="SELECT * FROM [Iteracoes]" 
                UpdateCommand="UPDATE [Iteracoes] SET [CodigoProjeto] = @CodigoProjeto, [NomeIteracao] = @NomeIteracao, [DataInicioIteracao] = @DataInicioIteracao, [DataTerminoIteracao] = @DataTerminoIteracao WHERE [CodigoIteracao] = @original_CodigoIteracao AND [CodigoProjeto] = @original_CodigoProjeto AND [NomeIteracao] = @original_NomeIteracao AND [DataInicioIteracao] = @original_DataInicioIteracao AND [DataTerminoIteracao] = @original_DataTerminoIteracao">
                <DeleteParameters>
                    <asp:Parameter Name="original_CodigoIteracao" Type="Int32" />
                    <asp:Parameter Name="original_CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="original_NomeIteracao" Type="String" />
                    <asp:Parameter Name="original_DataInicioIteracao" Type="DateTime" />
                    <asp:Parameter Name="original_DataTerminoIteracao" Type="DateTime" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="NomeIteracao" Type="String" />
                    <asp:Parameter Name="DataInicioIteracao" Type="DateTime" />
                    <asp:Parameter Name="DataTerminoIteracao" Type="DateTime" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="NomeIteracao" Type="String" />
                    <asp:Parameter Name="DataInicioIteracao" Type="DateTime" />
                    <asp:Parameter Name="DataTerminoIteracao" Type="DateTime" />
                    <asp:Parameter Name="original_CodigoIteracao" Type="Int32" />
                    <asp:Parameter Name="original_CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="original_NomeIteracao" Type="String" />
                    <asp:Parameter Name="original_DataInicioIteracao" Type="DateTime" />
                    <asp:Parameter Name="original_DataTerminoIteracao" Type="DateTime" />
                </UpdateParameters>
            </asp:SqlDataSource>
            <asp:FormView ID="FormView1" runat="server" DataKeyNames="CodigoIteracao" 
                DataSourceID="SqlDataSource2" oniteminserted="FormView1_ItemInserted" 
                onitemupdated="FormView1_ItemUpdated" 
                onitemdeleted="FormView1_ItemDeleted" BackColor="White" 
                BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" 
                ForeColor="Black" GridLines="Horizontal">
                <EditItemTemplate>
                    CodigoIteracao:
                    <asp:Label ID="CodigoIteracaoLabel1" runat="server" 
                        Text='<%# Eval("CodigoIteracao") %>' />
                    <br />
                    CodigoProjeto:
                    <asp:TextBox ID="CodigoProjetoTextBox" runat="server" 
                        Text='<%# Bind("CodigoProjeto") %>' />
                    <br />
                    NomeIteracao:
                    <asp:TextBox ID="NomeIteracaoTextBox" runat="server" 
                        Text='<%# Bind("NomeIteracao") %>' />
                    <br />
                    DataInicioIteracao:
                    <asp:TextBox ID="DataInicioIteracaoTextBox" runat="server" 
                        Text='<%# Bind("DataInicioIteracao") %>' />
                    <br />
                    DataTerminoIteracao:
                    <asp:TextBox ID="DataTerminoIteracaoTextBox" runat="server" 
                        Text='<%# Bind("DataTerminoIteracao") %>' />
                    <br />
                    <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                        CommandName="Update" Text="Inserir" />
                    &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                        CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
                </EditItemTemplate>
                <EditRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
                <EmptyDataTemplate>
                    <asp:LinkButton ID="LinkButton2" runat="server" CommandName="New">Novo</asp:LinkButton>
                </EmptyDataTemplate>
                <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
                <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
                <InsertItemTemplate>
                    CodigoProjeto:
                    <asp:TextBox ID="CodigoProjetoTextBox" runat="server" 
                        Text='<%# Bind("CodigoProjeto") %>' />
                    <br />
                    NomeIteracao:
                    <asp:TextBox ID="NomeIteracaoTextBox" runat="server" 
                        Text='<%# Bind("NomeIteracao") %>' />
                    <br />
                    DataInicioIteracao:
                    <asp:TextBox ID="DataInicioIteracaoTextBox" runat="server" 
                        Text='<%# Bind("DataInicioIteracao") %>' />
                    <br />
                    DataTerminoIteracao:
                    <asp:TextBox ID="DataTerminoIteracaoTextBox" runat="server" 
                        Text='<%# Bind("DataTerminoIteracao") %>' />
                    <br />
                    <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                        CommandName="Insert" Text="Insert" />
                    &nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" 
                        CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                </InsertItemTemplate>
                <ItemTemplate>
                    CodigoIteracao:
                    <asp:Label ID="CodigoIteracaoLabel" runat="server" 
                        Text='<%# Eval("CodigoIteracao") %>' />
                    <br />
                    CodigoProjeto:
                    <asp:Label ID="CodigoProjetoLabel" runat="server" 
                        Text='<%# Bind("CodigoProjeto") %>' />
                    <br />
                    NomeIteracao:
                    <asp:Label ID="NomeIteracaoLabel" runat="server" 
                        Text='<%# Bind("NomeIteracao") %>' />
                    <br />
                    DataInicioIteracao:
                    <asp:Label ID="DataInicioIteracaoLabel" runat="server" 
                        Text='<%# Bind("DataInicioIteracao") %>' />
                    <br />
                    DataTerminoIteracao:
                    <asp:Label ID="DataTerminoIteracaoLabel" runat="server" 
                        Text='<%# Bind("DataTerminoIteracao") %>' />
                    <br />
                    <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit">Editar</asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton3" runat="server" CommandName="Delete">Delete</asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton4" runat="server" CommandName="New">Novo</asp:LinkButton>
                    <br />
                </ItemTemplate>
                <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
            </asp:FormView>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                ConflictDetection="CompareAllValues" 
                ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" 
                DeleteCommand="DELETE FROM [Iteracoes] WHERE [CodigoIteracao] = @original_CodigoIteracao AND [CodigoProjeto] = @original_CodigoProjeto AND [NomeIteracao] = @original_NomeIteracao AND [DataInicioIteracao] = @original_DataInicioIteracao AND [DataTerminoIteracao] = @original_DataTerminoIteracao" 
                InsertCommand="INSERT INTO [Iteracoes] ([CodigoProjeto], [NomeIteracao], [DataInicioIteracao], [DataTerminoIteracao]) VALUES (@CodigoProjeto, @NomeIteracao, @DataInicioIteracao, @DataTerminoIteracao)" 
                OldValuesParameterFormatString="original_{0}" 
                SelectCommand="SELECT * FROM [Iteracoes] WHERE ([CodigoIteracao] = @CodigoIteracao)" 
                UpdateCommand="UPDATE [Iteracoes] SET [CodigoProjeto] = @CodigoProjeto, [NomeIteracao] = @NomeIteracao, [DataInicioIteracao] = @DataInicioIteracao, [DataTerminoIteracao] = @DataTerminoIteracao WHERE [CodigoIteracao] = @original_CodigoIteracao AND [CodigoProjeto] = @original_CodigoProjeto AND [NomeIteracao] = @original_NomeIteracao AND [DataInicioIteracao] = @original_DataInicioIteracao AND [DataTerminoIteracao] = @original_DataTerminoIteracao">
                <DeleteParameters>
                    <asp:Parameter Name="original_CodigoIteracao" Type="Int32" />
                    <asp:Parameter Name="original_CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="original_NomeIteracao" Type="String" />
                    <asp:Parameter Name="original_DataInicioIteracao" Type="DateTime" />
                    <asp:Parameter Name="original_DataTerminoIteracao" Type="DateTime" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="NomeIteracao" Type="String" />
                    <asp:Parameter Name="DataInicioIteracao" Type="DateTime" />
                    <asp:Parameter Name="DataTerminoIteracao" Type="DateTime" />
                </InsertParameters>
                <SelectParameters>
                    <asp:ControlParameter ControlID="GridView1" Name="CodigoIteracao" 
                        PropertyName="SelectedValue" Type="Int32" />
                </SelectParameters>
                <UpdateParameters>
                    <asp:Parameter Name="CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="NomeIteracao" Type="String" />
                    <asp:Parameter Name="DataInicioIteracao" Type="DateTime" />
                    <asp:Parameter Name="DataTerminoIteracao" Type="DateTime" />
                    <asp:Parameter Name="original_CodigoIteracao" Type="Int32" />
                    <asp:Parameter Name="original_CodigoProjeto" Type="Int32" />
                    <asp:Parameter Name="original_NomeIteracao" Type="String" />
                    <asp:Parameter Name="original_DataInicioIteracao" Type="DateTime" />
                    <asp:Parameter Name="original_DataTerminoIteracao" Type="DateTime" />
                </UpdateParameters>
            </asp:SqlDataSource>

        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
